package com.aegean.onlinebook.service.action;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.aegean.onlinebook.model.BigType;
import com.aegean.onlinebook.model.SmallType;
import com.aegean.onlinebook.service.business.ServiceBusiness;
import com.opensymphony.xwork2.ActionSupport;

@Controller("CUDSmallTypeAction")
@Scope("prototype")
public class CUDSmallType extends ActionSupport {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	@Resource
	ServiceBusiness business;
	private SmallType smallType;
	private int bigType_Id; 
	
	private boolean success;

	public boolean isSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	public SmallType getSmallType() {
		return smallType;
	}

	public void setSmallType(SmallType smallType) {
		this.smallType = smallType;
	}
	public int getBigType_Id() {
		return bigType_Id;
	}

	public void setBigType_Id(int bigType_Id) {
		this.bigType_Id = bigType_Id;
	}
	public String add() throws Exception {
		try {
			success=business.addSmallType(smallType,bigType_Id);
			return SUCCESS;
		} catch (Exception e) {
			e.printStackTrace();
			return  SUCCESS;
		}
	}
	public String edit() throws Exception {
		try {
			success=business.editSmallType(smallType);
			return SUCCESS;
		} catch (Exception e) {
			e.printStackTrace();
			return  SUCCESS;
		}
	}

}
